package com.daffodil.demo.controller;

import java.util.List;
import java.util.Map;

import com.daffodil.framework.controller.ReactiveBaseController;
import com.daffodil.framework.model.*;
import com.daffodil.framework.service.*;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.daffodil.core.entity.Page;
import com.daffodil.demo.constant.DemoConstant;

import io.swagger.annotations.Api;

@Api(value = "基础框架服务", tags = "基础框架服务")
@RestController
@RequestMapping(DemoConstant.API_CONTENT_PATH)
public class FrameworkController extends ReactiveBaseController {

    @DubboReference
    private IUserService userService;

    @DubboReference
    private IDeptService deptService;

    @DubboReference
    private IRoleService roleService;

    @DubboReference
    private IDictionaryService dictionaryService;

    @DubboReference
    private IAreaService areaService;

    @DubboReference
    private ITagService tagService;

    @DubboReference
    private IHolidaysService holidaysService;

    @GetMapping("/selectUserById")
    public User selectUserById(@RequestParam(value = "userId") String userId) {
        return userService.selectUserById(userId);
    }

    @GetMapping("/selectUserList")
    public List<User> selectUserList(User user, Page page) {
        return userService.selectUserList(user, page);
    }

    @GetMapping("/selectDeptById")
    public Dept selectDeptById(@RequestParam(value = "deptId") String deptId) {
        return deptService.selectDeptById(deptId);
    }

    @GetMapping("/selectDeptList")
    public List<Dept> selectDeptList(Dept dept, Page page) {
        return deptService.selectDeptList(dept, page);
    }

    @GetMapping("/selectRoleId")
    public Role selectRoleById(@RequestParam(value = "roleId") String roleId) {
        return roleService.selectRoleById(roleId);
    }

    @GetMapping("/selectRoleList")
    public List<Role> selectRoleList(Role role, Page page) {
        return roleService.selectRoleList(role, page);
    }

    @GetMapping("/selectDictionaryByLabel")
    public List<Dictionary> selectDictionaryByLabel(@RequestParam(value = "dictLabel") String dictLabel){
        return dictionaryService.selectDictionaryByLabel(dictLabel);
    }

    @GetMapping("/selectAreaListByParentId")
    public List<Area> selectAreaListByParentId(@RequestParam(value = "parentId") String parentId){
        return areaService.selectAreaListByParentId(parentId);
    }

    @GetMapping("/selectTagByLabel")
    public List<Tag> selectTagByLabel(@RequestParam(value = "tagLabel") String tagLabel){
        return tagService.selectTagByLabel(tagLabel);
    }

    @GetMapping("/selectHolidaysByDate")
    public byte[] selectDaysByYear(@RequestParam(value = "year") Integer year){
        return holidaysService.selectDaysByYear(year);
    }

    @GetMapping("/multiselectDaysByYear")
    public Map<Integer, byte[]> multiselectDaysByYear(@RequestParam(value = "startYear") Integer startYear, @RequestParam(value = "endYear") Integer endYear){
        return holidaysService.multiselectDaysByYear(startYear, endYear);
    }
}
